package Hot100.BackTracking;

import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;

public class subsets {
    public static void main(String[] args) {
        int[] nums = {0};
        System.out.println(new subsets().subsets(nums));
    }
    List<List<Integer>> result = new ArrayList<>();
    LinkedList<Integer> path = new LinkedList<>();
    public List<List<Integer>> subsets(int[] nums) {
        result.add(new ArrayList<>());
        for (int i = 1; i <= nums.length  ; i++) {
            backTracking(nums,0,i);
        }
        return result;
    }
    public void backTracking(int[] nums,int startIndex,int length){
        if(path.size() == length){
            result.add(new ArrayList<>(path));
            return;
        }
        for (int i = startIndex; i <nums.length ; i++) {
            path.add(nums[i]);
            backTracking(nums,i + 1,length);
            path.removeLast();
        }
    }
}
